package com.example.demo1;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class Test1 {

    public static void main(String[] args) {

        // ClassPathXmlApplicationContext 是 BeanFactory的字类 获取classPath下面的xml 还有一个通过 注解的方式来获取相关的bean
        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("bean.xml");

        //根据bean的名称 和类型去获取这个 bean
        User user = classPathXmlApplicationContext.getBean("user", User.class);

        List<String> names = user.getFriends().getNames();
        names.forEach(s -> {
            System.out.println("s = " + s);
        });

    }
}
